package com.multi.thread.chapter03.demo12;

import java.io.IOException;
import java.io.PipedInputStream;

public class ReadData {
	
	public void readMethod(PipedInputStream in) {
		try {
			System.out.println("read : " + System.currentTimeMillis());
			byte[] array = new byte[20];
			int readLength = in.read(array);
			while (readLength != -1) {
				System.out.println("readLength = " + readLength);
				String newData = new String(array, 0 , readLength);
				System.out.println(newData);
				readLength = in.read(array);
			}
			System.out.println();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
